using BLL;
using DAL;
using IBLL;
using IDAL;
using NLog.Web;
using Microsoft.EntityFrameworkCore;

namespace work314API
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var builder = WebApplication.CreateBuilder(args);
            builder.Services.AddControllers().AddJsonOptions(x =>
            {
                x.JsonSerializerOptions.PropertyNamingPolicy = null;
            });
            // Add services to the container.

            builder.Services.AddControllers();
            // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
            builder.Services.AddEndpointsApiExplorer();
            builder.Services.AddSwaggerGen();
            builder.Services.AddDbContext<MyDbContext>(x =>
            {
                x.UseSqlServer(builder.Configuration.GetConnectionString("ConStr"));
            });
            builder.Services.AddScoped(typeof(IBaseDAL<>),typeof(BaseDAL<>));
            builder.Services.AddScoped<IUserBLL,UserBLL>();
            builder.Host.UseNLog();
            var app = builder.Build();
            app.UseCors(x=>x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
            // Configure the HTTP request pipeline.
            if (app.Environment.IsDevelopment())
            {
                app.UseSwagger();
                app.UseSwaggerUI();
            }

            app.UseHttpsRedirection();

            app.UseAuthorization();

            app.UseStaticFiles();

            app.MapControllers();

            app.Run();
        }
    }
}
